package;

/**
 * ...
 * @author liwei
 */

class Counter 
{
	private static var instance:Counter;
	private var suffix:String = ".77a5acfe-d2e0-47c0-b9c7-5a71a88fe0af";
	public function new() 
	{
		
	}
	
	public static function getInstance():Counter {
		if (instance == null) {
			instance = new Counter();
		}
		return instance;
	}
	public function add(name:String, ?inc:Int = 1):Int {
		var path:String = name + suffix;
		var count:Int = cast KV.getInstance().get(path);
		count += inc;
		KV.getInstance().set(path, count+"");
		return count;
	}
	public function delete(name:String):Void {
		KV.getInstance().delete(name + suffix);
	}
}